using System;
using System.Runtime.CompilerServices;
using System.Serialization;

namespace Nsb.Classes
{
    [IgnoreNamespace]
    public static class Rx
    {
        public static readonly RegularExpression HasEndSpace = new RegularExpression(@"[^\s]+\s+$");
        public static readonly RegularExpression WhiteSpace = new RegularExpression(@"\s+");
        public static readonly RegularExpression CssFilter = new RegularExpression(@"(px|pt|em)$");
        public static readonly RegularExpression EmailFilter = (RegularExpression)Script.Literal(@"/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i");
        public const string Placeholder = "<b>&nbsp;</b>";
        //public static readonly RegularExpression PlaceholderRx = new RegularExpression("^" + Placeholder + "$", "");


        [AlternateSignature]
        public static extern string PrettyJson(object jo);
        
        public static string PrettyJson(object jo, string indent)
        {
            return Json.Stringify(jo, delegate(string n, object o) { return o; }, Arguments.Length > 1 ? indent : "\t");
        }

    }
}
